#!/bin/bash

# 定义备份目录
BACKUP_DIR="/path/to/backup"

# 恢复所有表的规则
sudo iptables-restore < $BACKUP_DIR/iptables-all.rules

# 或者，单独恢复每个表的规则

# 恢复 filter 表的规则
sudo iptables-restore -t filter < $BACKUP_DIR/iptables-filter.rules

# 恢复 nat 表的规则
sudo iptables-restore -t nat < $BACKUP_DIR/iptables-nat.rules

# 恢复 mangle 表的规则
sudo iptables-restore -t mangle < $BACKUP_DIR/iptables-mangle.rules

# 恢复 raw 表的规则
sudo iptables-restore -t raw < $BACKUP_DIR/iptables-raw.rules

echo "iptables rules restore completed successfully."